#!/bin/bash
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
wget http://47.76.94.164/docker/daemon.json -O /etc/docker/daemon.json
systemctl restart docker
printf "\e[32m正在拉取镜像...\e[0m\n"
docker pull phalanetwork/phala-pruntime-v2-dcap-with-handover:25022401

# 获取所有运行中的容器并停止和删除容器
Get_docker_name=$(docker ps --format "{{.Names}}")

if [ -z "$Get_docker_name" ]; then
  echo -e "\e[32m没有运行的容器:\e[0m"
else
  echo -e "\e[32m正在运行的容器:\e[0m"
  echo -e "\e[34m$Get_docker_name\e[0m"
  echo -e "\e[31m已经停止容器：\e[0m" 
  docker stop $Get_docker_name
  echo -e "\e[31m删除容器：\e[0m"
  docker rm $Get_docker_name
  
fi

mkdir -p /var/phala/

cp -a /var/phala-dcap-data/./* /var/phala/

find /var/phala/ -type d -name "24032901" 2>/dev/null -execdir mv {} ../  \;

echo -e "\e[34m操作完成...\e[0m"
exit
